package com.mashibing.servicesms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.dto.servicesms.request.SmsSendRequest;
import com.mashibing.servicesms.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author gorkr
 * @date 2022/05/29 15:16
 **/
@RestController
@RequestMapping("/send")
@Slf4j
public class SendController {

    @Resource
    private SmsService smsService;

    @PostMapping("/sms-template")
    public ResponseResult send(@RequestBody SmsSendRequest smsSendRequest){

        JSONObject param = (JSONObject) JSON.toJSON(smsSendRequest);
        log.info("/send/alisms-template   request："+param.toString());
        return smsService.sendSms(smsSendRequest);
    }

}
    